#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1005;

int n, m, p1, p2;
struct Ask {
  int x, y, z;
} ask[N];
int f[N], d[N];
set<int> st[N][2];
int dp[N][N];
void init(int n) {
  rep(i, 1, n) {
    f[i] = i, d[i] = 0;
    st[i][0].clear(), st[i][1].clear();
    st[i][0].insert(i);
  }
}
int find(int x) {
  if (f[x] == x) return x;
  int y = find(f[x]);
  d[x] = d[x] ^ d[f[x]];
  return f[x] = y;
}
void merge(set<int>& x, set<int>& y) {
  if (x.size() < y.size()) swap(x, y);
  for (int v : y) x.insert(v);
}
void merge(int x, int y, int z) {
  int fx = find(x), fy = find(y);
  if (fx == fy) return;
  int k = d[x] ^ d[y] ^ z;
  d[fy] = k;
  f[fy] = fx;
  merge(st[fx][0], st[fy][k]);
  merge(st[fx][1], st[fy][k ^ 1]);
}
void solve() {
  rep(i, 1, m) {
    string res;
    cin >> ask[i].x >> ask[i].y >> res;
    ask[i].z = (res == "no");
  }
  if (p1 == p2) {
    cout << "no" << endl;
    return;
  }
  init(n);
  rep(i, 1, m) merge(ask[i].x, ask[i].y, ask[i].z);
  int pre = 0;
  vector<int> a;
  dp[0][0] = 1;
  rep(i, 1, n) {
    if (f[i] != i) continue;
    a.push_back(i);
    rep(j, 0, p1) dp[i][j] = 0;
    rep(j, 0, 1) {
      int cnt = st[i][j].size();
      rep(k, 0, p1 - cnt) {
        if (dp[pre][k] == 0) continue;
        int v = k + cnt;
        if (dp[pre][k] > 2)
          dp[i][v] = dp[pre][k];
        else
          dp[i][v] |= (1 << j);
      }
    }
    pre = i;
  }
  if (dp[pre][p1] == 0 || dp[pre][p1] > 2)
    cout << "no" << endl;
  else {
    set<int> ans;
    per(i, a.size() - 1, 0) {
      int id = a[i];
      int k = dp[id][p1] - 1;
      for (int x : st[id][k]) ans.insert(x), p1--;
    }
    for (int x : ans) cout << x << endl;
    cout << "end" << endl;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (cin >> m >> p1 >> p2) {
    n = p1 + p2;
    if (!n && !m) break;
    solve();
  }
  return 0;
}